
cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    onLoad () {

    },

    /**
     * 当碰撞产生的时候调用
     * @param  {Collider} other 产生碰撞的另一个碰撞组件
     * @param  {Collider} self  产生碰撞的自身的碰撞组件
     */
    onCollisionEnter: function (other, self) {
        var js_block = other.node.parent.getComponent('block')
        if(js_block){
            if(js_block.score == 0){//判断得到几分
                if(other.tag == 10 && self.tag == 1000){//英雄的小白点和块的小白点碰撞
                    js_block.score = 2
                    js_block.isPZ = true
                    game.addScore(2)
                    cc.log('得两分')
                }else if(other.tag == 11 && self.tag == 1000){//英雄的小白点和块碰撞
                    js_block.score = 1
                    js_block.isPZ = true
                    game.addScore(1)
                    cc.log('得yi分')
                }
            }

            if(game.isGetScore == -1){
                if(other.tag == 10 && self.tag == 1000){//英雄的小白点和块的小白点碰撞
                    game.isGetScore = 2
                    cc.log('2222222222222222')
                }else if(other.tag == 11 && self.tag == 1000){//英雄的小白点和块碰撞
                    game.isGetScore = 1
                    cc.log('1111111111111111')
                }else if(other.tag == 11 && self.tag == 1001){//英雄的块和块碰撞
                    game.isGetScore = 0
                    var pos_blockDian = js_block.pos_dianWorld
                    var pos_hero = game.hero.getPosition()
                    var pos_cha = pos_blockDian.sub(pos_hero)
                    if(pos_cha.x > 0){//英雄在块上白点的左边
                        game.gameType = 2
                        var act_1 = cc.rotateTo(0.5,30)
                        var act_2 = cc.callFunc(function(){
                            game.gameOver()
                        }.bind(this))
                        game.hero.runAction(cc.sequence(act_1,act_2))
                    }else{//英雄在块上白点的右边
                        game.gameType = 2
                        var act_1 = cc.rotateTo(0.5,-30)
                        var act_2 = cc.callFunc(function(){
                            game.gameOver()
                        }.bind(this))
                        game.hero.runAction(cc.sequence(act_1,act_2))
                    }
                    cc.log(pos_blockDian)
                    cc.log(pos_hero)
                    cc.log('hero滑到')
                }
            }
            
        }
    }

    // update (dt) {},
});
